<template>
	<view class="selectDateBox">
		<view class="dateBox" @click="showDate = true">
			<view class="date">{{date}}</view>
			<image src="@/static/images/date.png" style="width: 28rpx; height: 28rpx;"></image>
		</view>
		<u-datetime-picker :show="showDate" v-model="dateValue" mode="date" @confirm="selectDate"></u-datetime-picker>
	</view>
</template>

<script>
	export default {
		name: "select-date",
		props: {
			date: {
				type: [String],
				default: ""
			}
		},
		data() {
			return {
				dateValue: Number(new Date()),
				showDate: false,
			};
		},
		methods: {
			selectDate(e) {
				let date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
				this.showDate = false
				this.$emit('selectDate', date)
			}
		}
	}
</script>

<style scoped lang="scss">
	.selectDateBox {
		width: 100%;
		height: 100%;
	}

	.dateBox {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		color: #ffffff;
		font-size: 28rpx;
		padding: 0rpx 30rpx;
	}
</style>